package com.xxx.modules.controller;;
import com.xxx.modules.service.ComplainService;
import com.xxx.modules.entity.Complain;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * complain
 *
 * @author 北易航
 * @since 1.0.0 2022-12-28
 */
@RestController
@RequestMapping("/common/complain")
@Api(tags="complain")
public class ComplainController {
    @Autowired
    private ComplainService complainService;

    /**
    *  获取所有投诉建议
    * @param pageNum
    * @param pageSize
    * @param complain
    * @return
    */

    @GetMapping("/getComplainInfo")
    @ApiOperation("获取所有投诉建议")
    public Result getComplainInfo(Complain complain, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Complain> data = complainService.selectComplainInfo(complain,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存投诉建议
    * @param complain
    * @return
    */
    @PostMapping("/saveComplainInfo")
    @ApiOperation("保存投诉建议")
    public Result saveComplainInfo(@RequestBody Complain complain){
        complainService.saveComplainInfo(complain);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新投诉建议
     * @param complain
     * @return
     */

    @PutMapping("/updateComplainInfo")
    @ApiOperation("更新投诉建议")
    public Result updateComplainInfo(@RequestBody Complain complain){
        complainService.updateComplainInfo(complain);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除投诉建议
     * @param id
     * @return
     */
    @DeleteMapping("/delComplainInfo")
    @ApiOperation("根据id删除投诉建议")
    public Result delComplainInfo(Integer id){
        complainService.delComplainInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除投诉建议
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchComplainInfo")
    @ApiOperation("根据id集合批量删除投诉建议")
    public Result delBatchComplainInfo(String idList){
        complainService.delBatchComplainInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}